package com.cskaoyan.service;

import com.cskaoyan.bean.Address;
import com.cskaoyan.bean.AddressExample;
import com.cskaoyan.mapper.AddressMapper;
import com.cskaoyan.vo.AddressVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2021/4/9 - 17:45
 */
@Service
public class AddressServiceImpl implements AddressService {


    @Autowired
    AddressMapper addressMapper;
    @Override
    public AddressVo qurey(Integer page, Integer limit, String sort, String order) {

        // 分页
        PageHelper.startPage(page,limit);

        AddressExample addressExample = new AddressExample();
        List<Address> addresses = addressMapper.selectByExample(addressExample);

        PageInfo<Address> addressPageInfo = new PageInfo<>();
        long total = addressPageInfo.getTotal();

        AddressVo addressVo = new AddressVo();
        addressVo.setItems(addresses);
        addressVo.setTotal(total);

        return addressVo;

    }
}
